{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# div0vem\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1. 符号标记"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "|符号|意思|\n",
    "|-----|----|\n",
    "|$\\Omega$| 区域|\n",
    "|$T_h$| polyhedral triangulation |\n",
    "|$E$ | element|\n",
    "|$f$| face |\n",
    "|$P_k$| polynomial space of order k \\geq 0|\n",
    "|$\\boldsymbol{P}_k$| vector polynomial space|\n",
    "|$V_E$| local space|\n",
    "|$V_h^E$| the golbal H(div) conforming vritual element space|\n",
    "|$RM(f)$| the space of rigid motion |\n",
    "|$S_{d-1}$| the space of anti-symmeteric $(d-1) \\times (d-1)$ matrices|\n",
    "|$V_h^t$| the element boundary space|\n",
    "|$\\tau_i$| orthogonal unit tangential vectors on the face|\n",
    "|$V_h$| virtual element space|\n",
    "|$\\mathbb{P}_{k-1}^s$| the space of symmetric matrics|\n",
    "|$\\tilde{J}_{\\partial E}^{\\tau_i}$| the difference of $v^t$ and $ v^{div}$ on the tangential $\\tau_i$ difference|"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " #### 2. the steady-state incompressibleStokes roblem "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "$$\n",
    "\\begin{cases}\n",
    "-div(2 \\nu \\epsilon(u)) + \\nabla p = f \\quad in \\Omega\\\\\n",
    "\\nabla \\cdot u=0 \\quad in \\Omega\\\\\n",
    "u = 0 \\quad on \\partial \\Omega\n",
    "\\end{cases}\n",
    "$$\n",
    "\n",
    "其中 $\\epsilon(u) = \\frac{1}{2} (\\nabla u+ \\nabla u^T)$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "在斯托克斯方程流动中, 雷诺数非常低, N-S方程中的核对流项加速度$(u_t+u\\cdot \\nabla u=0)$ 被忽略, 然后, 对于不可压缩流的稳定流量有: $\\nabla p = \\mu \\nabla \\times \\omega 其中[\\omega = \\nabla \\times u]$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "stokes'stress constitutive equation :\n",
    "\n",
    "$$\n",
    "\\tau = 2\\mu \\epsilon\\\\\n",
    "\\nabla \\cdot \\tau = 2\\mu \\nabla \\cdot \\epsilon = \\mu \\nabla^2 u\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "故根据动量守恒定律有:\n",
    "\n",
    "$$\n",
    "\\rho D_\\tau u = f - \\nabla p + div \\sigma (u) = f+div(-pI+\\sigma(u))\n",
    "$$\n",
    "\n",
    "化简有:\n",
    "\n",
    "$$\n",
    "-div(2 \\nu \\epsilon(u)) + \\nabla p = f\n",
    "$$\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "此外, 不可压缩流: \n",
    "\n",
    "$$\n",
    "D_\\tau \\rho = 0 \\iff div u =0 \\iff \\nabla \\cdot u =0\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "#### 3. 自由度"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "对于空间$\\mathbb P_k(\\mathbb R^d)$ 的维数用 $\\pi_{k, d}$ 表示:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "$$\n",
    "\\begin{align}\n",
    "\\pi_{k, 1} & = k + 1\\\\\n",
    "\\pi_{k, 2} & = \\frac{(k+1)(k+2)}{2}\\\\\n",
    "\\pi_{k, 3} & = \\frac{(k+1)(k+2)(k+3)}{6}\\\\\n",
    "\\end{align}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "$$\n",
    "(\\mathrm{div} (\\mathbb W\\mathbf u), 1) = (\\frac{1}{2}(\\nabla \\mathbf u + \\nabla \\mathbf u^T), \\mathbb W) + (\\mathrm{div} \\mathbb W, \\mathbf u)\n",
    "$$\n",
    "\n",
    "$$\n",
    "(\\mathrm{div} (\\mathbb W\\mathbf u), 1) = <\\mathbb W\\mathbf n, \\mathbf u>_{\\partial E}=\\left<(\\mathbb W\\mathbf n\\cdot \\mathbf n)\\mathbf n + \\sum (\\mathbb W\\mathbf n\\cdot \\mathbf \\tau_i)\\mathbf \\tau_i , (\\mathbf u\\cdot\\mathbf n)\\mathbf n + \\sum (\\mathbf u\\cdot\\mathbf \\tau_i)\\mathbf \\tau_i\\right>_{\\partial E} \n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 边上的多项式空间"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\phi_{m,n} = \\frac{p^p}{m!n!}\\prod_{l_0 = 0}^{m - 1}\n",
    "(\\lambda_0 - \\frac{l_0}{p}) \\prod_{l_1 = 0}^{n-1}(\\lambda_1 -\n",
    "\\frac{l_1}{p}).\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 单元内部的单项式空间"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 单项式空间\n",
    "\n",
    "|$\\mathbf \\alpha$ | $\\alpha$ | 单项式  $m_\\alpha$ | $\\nabla m_{\\alpha}$ |$\\Delta m_\\alpha$ |\n",
    "|--------|---------|\n",
    "|(0, 0)  | 0|  1 |  (0, 0) | 0 |\n",
    "|(1, 0)  | 1| $\\frac{x - x_E}{h_E}$ | $(\\frac{1}{h_E}, 0)$| 0 |\n",
    "|(0, 1)  | 2| $\\frac{y - y_E}{h_E}$ | $(0, \\frac{1}{h_E})$| 0 |\n",
    "|(2, 0)  | 3| $(\\frac{x - x_E}{h_E})^2$ | $(\\frac{2(x - x_E)}{h_E^2}, 0)$| $\\frac{2}{h_E^2}$|\n",
    "|(1, 1)  | 4| $\\frac{(x - x_E)(y - y_E)}{h_E^2}$ | $(\\frac{y - x_E}{h_E^2}, \\frac{x - x_E}{h_E^2})$ | 0 |\n",
    "|(0, 2)  | 5| $(\\frac{y - y_E}{h_E})^2$ |$(0, \\frac{2(y - y_E)}{h_E^2})$ | $\\frac{2}{h_E^2}$|\n",
    "|(3, 0)  | 6| $(\\frac{x - x_E}{h_E})^3$ | $(\\frac{3(x - x_E)^2}{h_E^3}, 0)$|$\\frac{6(x - x_E)}{h_E^3}$\n",
    "|(2, 1)  | 7| $\\frac{(x - x_E)^2(y - y_E)}{h_E^3}$ |$(\\frac{2(x - x_E)(y - y_E)}{h_E^3}, \\frac{(x - x_E)^2}{h_E^3})$  | $\\frac{2(y - y_E)}{h_E^3}$\n",
    "|(1, 2)  | 8| $\\frac{(x - x_E)(y - y_E)^2}{h_E^3}$ |$(\\frac{(y - y_E)^2}{h_E^3}, \\frac{2(x - x_E)(y - y_E)}{h_E^3})$  |  $\\frac{2(x - x_E)}{h_E^3}$\n",
    "|(0, 3)  | 9|$(\\frac{y - y_E}{h_E})^3$ | $(0, \\frac{3(y - y_E)^2}{h_E^3})$|$\\frac{6(y - y_E)}{h_E^3}$\n",
    "|(4, 0)  | 10| $(\\frac{x - x_E}{h_E})^4$ | $(\\frac{4(x - x_E)^3}{h_E^4}, 0)$|$\\frac{12(x - x_E)^2}{h_E^4}$\n",
    "|(3, 1)  | 11| $\\frac{(x - x_E)^3(y - y_E)}{h_E^4}$ |$(\\frac{3(x - x_E)^2(y - y_E)}{h_E^4}, \\frac{(x - x_E)^3}{h_E^4})$  | $\\frac{6(x-x_E)(y - y_E)}{h_E^4}$\n",
    "|(2, 2)  | 12| $\\frac{(x - x_E)^2(y - y_E)^2}{h_E^4}$ |$(\\frac{2(x - x_E)(y - y_E)^2}{h_E^4}, \\frac{2(x - x_E)^2(y-y_E)}{h_E^4})$  | $\\frac{2(y-y_E)^2+2(x - x_E)^2}{h_E^4}$\n",
    "|(1, 3)  | 13| $\\frac{(x - x_E)(y - y_E)^3}{h_E^4}$ |$(\\frac{(y - y_E)^3}{h_E^4}, \\frac{3(x-x_E)(y - y_E)^2}{h_E^4})$  | $\\frac{6(x-x_E)(y - y_E)}{h_E^4}$\n",
    "|(0, 4)  | 14| $(\\frac{y - y_E}{h_E})^4$ | $(0,\\frac{4(y - y_E)^3}{h_E^4})$|$\\frac{12(y - y_E)^2}{h_E^4}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "|$\\mathbf \\alpha$ | $\\alpha$ | 单项式  $m_\\alpha$ | $\\nabla m_{\\alpha}$ |$\\Delta m_\\alpha$ |\n",
    "|--------|---------|\n",
    "|(0, 0)  | 0|  1 |  (0, 0) | 0 |\n",
    "|(1, 0)  | 1| $x$ | $(1, 0)$| 0 |\n",
    "|(0, 1)  | 2| $y$ | $(0, 1)$| 0 |\n",
    "|(2, 0)  | 3| $x^2$ | $(2x, 0)$| |\n",
    "|(1, 1)  | 4| $xy$ | $(y, x)$ | 0 |\n",
    "|(0, 2)  | 5| $y^2$ |$(0, 2y)$ ||\n",
    "|(3, 0)  | 6| $x^3$|$(3x^2, 0)$ | |\n",
    "|(2, 1)  | 7| $x^2y$ |$(2xy, x^2)$  |  |\n",
    "|(1, 2)  | 8| $xy^2$ |$(y^2, 2xy))$  |   |\n",
    "|(0, 3)  | 9| $y^3$ | $(0, 3y)$||\n",
    "|(4, 0)  | 10| $x^4$ | $(4x^3, 0)$| |\n",
    "|(3, 1)  | 11| $x^3y$ |$(3x^2y, x^3)$  ||\n",
    "|(2, 2)  | 12| $x^2y^2$ |$(2xy^2, 2x^2y)$  | |\n",
    "|(1, 3)  | 13| $xy^3$ |$(y^3, 3xy^2)$  ||\n",
    "|(0, 4)  | 14| $y^4$ | $(0,4y^3)$||"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\mathbf V_E = \\{\\boldsymbol v\\in\\boldsymbol H(\\text{div}) \\cap \\boldsymbol H(\\mathbf{curl}):\\boldsymbol v\\cdot\\boldsymbol n\\in P_k(f) \\forall f\\subset \\partial E, \\text{div}\\,\\boldsymbol v\\in P_{k-1}(E)), \\boldsymbol{curl}\\,v\\in\\boldsymbol P_{k-1}(E)\\}\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\mathbf V_f := \\boldsymbol P_k(f)\n",
    "$$\n",
    "\n",
    "或者：\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "\\mathbf V_f := \\boldsymbol P_{k-1}(f) + \\mathbf{RM}(f)\\\\\n",
    "\\mathbf{RM}(f) := \\{ c + R\\boldsymbol x, c, R \\in \\mathbb R \\}\n",
    "\\end{aligned}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "自由度为 \n",
    "\n",
    "$$\n",
    "n_k^{div} = N(k+1)+\\frac{k(k+1)}{2} - 1 + \\frac{k(k+1)}{2} = N(k+1)+k(k+1) - 1 = (N+k)(k+1) - 1\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\boldsymbol \\Phi^{div} = (\\boldsymbol v_0, \\boldsymbol v_1, \\cdots, \\boldsymbol v_{n_k^{div}})\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\boldsymbol \\Phi^{t}_i = (\\boldsymbol v_{i, 0}^t, \\boldsymbol v_{i, 1}^t, \\cdots, \\boldsymbol v_{i, n_k^{f}}^t)\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\boldsymbol \\Phi = (\\boldsymbol \\Phi^{div}, \\boldsymbol \\Phi^{t}_0, \\boldsymbol \\Phi^{t}_1, \\cdots, \\boldsymbol \\Phi^{t}_{n_f})\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\epsilon_E^w(\\boldsymbol v)\\in \\mathbb P_{k-1}^s(E)\n",
    "$$\n",
    "\n",
    "自由度的个数：\n",
    "\n",
    "$$\n",
    "3\\frac{k(k+1)}{2}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\mathbb P_{0}^s(E)$:\n",
    "\n",
    "$$\n",
    "\\mathbb w_0 = \n",
    "\\begin{pmatrix}\n",
    "1 & 0 \\\\ 0 & 0\n",
    "\\end{pmatrix},\\quad\n",
    "\\mathbb w_1 = \n",
    "\\begin{pmatrix}\n",
    "0 & 0 \\\\ 0 & 1\n",
    "\\end{pmatrix},\\quad\n",
    "\\mathbb w_2 = \n",
    "\\begin{pmatrix}\n",
    "0 & \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} & 0\n",
    "\\end{pmatrix}\\\\\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\mathbb P_{k-1}^s(E)$:\n",
    "$$\n",
    "\\boldsymbol M_{k-1} = (m_0, m_1, \\cdots, m_{n_{k-1}})\n",
    "$$\n",
    "$$\n",
    "\\mathbb W = (\\mathbb w_0\\boldsymbol M_{k-1}, \\mathbb w_1\\boldsymbol M_{k-1}, \\mathbb w_2\\boldsymbol M_{k-1})\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "G_{k-1} = \\begin{pmatrix}\n",
    "\\int_{E} \\boldsymbol M^T_{k-1}\\boldsymbol M_{k-1} & \\boldsymbol 0 & \\boldsymbol 0\\\\\n",
    "\\boldsymbol 0 & \\int_{E} \\boldsymbol M^T_{k-1}\\boldsymbol M_{k-1} & \\boldsymbol 0\\\\\n",
    "\\boldsymbol 0 & \\boldsymbol 0 & \\int_{E}\\boldsymbol M^T_{k-1}\\boldsymbol M_{k-1}\\\\\n",
    "\\end{pmatrix}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{aligned}\n",
    "B =& -\\int_E \\text{div}\\mathbb W^T(\\boldsymbol \\Phi^{div}, 0) + \\int_{\\partial E} \\mathbb W^T\\boldsymbol n \\cdot \\boldsymbol n (\\boldsymbol \\Phi^{div}, 0)\\cdot \\boldsymbol n +\\sum \\int_{\\partial E}\\mathbb W^T\\boldsymbol n \\cdot \\boldsymbol \\tau_i\\boldsymbol(0, \\Phi^t)\\cdot\\boldsymbol\\tau_i\\\\\n",
    "\\end{aligned}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "$$\n",
    "B_1= \\int_E \\text{div}\\mathbb W^T (\\boldsymbol \\Phi^{div}, 0) = \\int_E \\left(\n",
    "\\begin{pmatrix}\n",
    "\\boldsymbol M_{k-1,x} \\\\ 0\n",
    "\\end{pmatrix},\n",
    "\\begin{pmatrix}\n",
    "0 \\\\ \\boldsymbol M_{k-1,y}\n",
    "\\end{pmatrix},\n",
    "\\frac{1}{\\sqrt{2}} \n",
    "\\begin{pmatrix}\n",
    "\\boldsymbol M_{k-1,y} \\\\ \\boldsymbol M_{k-1,x}\n",
    "\\end{pmatrix}\n",
    "\\right)^T\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
